<template>
  <div class="home">
    <swiper />
    <div class="section" v-for="(item,index) in songsList" :key="index">
      <div class="section-title">{{item.name}}</div>
      <content-list :contentList="item.list"></content-list>
    </div>
  </div>
</template>

<script>
import Swiper from "../components/Swiper";
import contentList from '../components/ContentList';
import {getAllStroe} from "../api/shop";
import {getAllFoodsByPaging} from "../api/food";
export default {
  name: 'home',
  components: {
    Swiper,
    contentList
  },
  data () {
    return {
      songsList: [
        {name:"热门店铺",list: []},
        {name:"热门食品",list: []}
      ]
    }
  },
  created () {
    this.getShopList();
    this.getFoodList();
  },
  methods: {
    //获取前十个店铺
    getShopList(){
      getAllStroe(1,10).then(res=>{
        this.songsList[0].list = res.data.obj;
      }).catch(error=>{
        console.log(error)
      })
    },
    //获取前10个菜品
    getFoodList(){
      getAllFoodsByPaging(1,10).then(res=>{
        this.songsList[1].list = res.data.obj;
      }).catch(error=>{
        console.log(error)
      })
    }

  }
}
</script>

<style lang="scss" scoped>
@import '../assets/css/home.scss';
</style>
